#include "hw5.h"

/*****找到父节点*****/
int main()
{
    t0 = NULL;
    t1 = (btree)malloc(sizeof(btnode));
    t2 = (btree)malloc(sizeof(btnode));
    t3 = (btree)malloc(sizeof(btnode));
    t4 = (btree)malloc(sizeof(btnode));
    t5 = (btree)malloc(sizeof(btnode));
    t6 = (btree)malloc(sizeof(btnode));
    t7 = (btree)malloc(sizeof(btnode));
    t8 = (btree)malloc(sizeof(btnode));

    btree f;

    /***第1棵二叉树***/
    t_init();
    t1->lc = t2;
    t1->rc = t3;
    t2->lc = t4;
    t2->rc = t5;
    t3->lc = t6;
    t3->rc = t7;
    f = findF(2, t1);
    if (f == nullptr)
    {
        printf("未找到！\n");
    }
    else
    {
        printf("%d\n", f->data);
    }
    /***第1棵二叉树***/

    /***第2棵二叉树***/
    t_init();
    t1->lc = t2;
    t1->rc = t3;
    t2->lc = t4;
    t2->rc = t5;
    t3->rc = t6;
    t5->lc = t7;
    f = findF(8, t1);
    if (f == nullptr)
    {
        printf("未找到！\n");
    }
    else
    {
        printf("%d\n", f->data);
    }
    /***第2棵二叉树***/

    system("pause");
}
/*****找到父节点*****/